package com.xin.controller;

import com.xin.annoations.Permission;
import com.xin.constants.CommonResult;
import com.xin.entity.shop.ShopOperateLogEntity;
import com.xin.service.ShopOperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 店铺审核日志
 */
@RestController
@RequestMapping("/shopOperateLog")
@Api(tags = "店铺审核相关")
@Permission(value = "店铺审核相关",sn="shopOperateLog")
public class ShopOperateLogController {
    @Resource
    private ShopOperateLogService shopOperateLogService;

    /**
     * 店铺审核
     * @return
     */
    @PostMapping("/add")
    @Permission(value = "店铺审核",sn="shopOperateLog:add")
    @ApiOperation("审核店铺")
    public CommonResult<?> add(@RequestBody  @Valid ShopOperateLogEntity operateLogEntity, HttpServletRequest request){
        return this.shopOperateLogService.add(operateLogEntity,request)>0?CommonResult.success(null,"审核成功"):CommonResult.error(499,"网络异常");
    }

    /**
     * 查看店铺审核记录
     * @param shopId
     * @return
     */
    @Permission(value = "查找该店铺的审核记录",sn="shopOperateLog:findByShopId")
    @ApiOperation("查看店铺的审核记录")
    @GetMapping("/findByShopId")
    public CommonResult<?> findByShopId(Long shopId){
        return CommonResult.success(this.shopOperateLogService.findByShopId(shopId),"请求成功");
    }
}
